#include "stdafx.h"
#include "StartUi.h"
#include "Tools.h"


CStartUi::CStartUi()
	: m_StartBackImg(NULL)
	, m_StartImg2(NULL)
	, m_JumpImgId(0)
	, m_MenuImg(NULL)
{
	m_JumpSpeed = 10;
	m_Pos.x = 0;
	m_Pos.y = 0;
}


CStartUi::~CStartUi()
{
}

void CStartUi::SetImage(IplImage * backimg, IplImage * jumpimg[10], IplImage * menuimg)
{
	m_StartBackImg = backimg;
	m_StartImg2 = cvCloneImage(backimg);
	m_MenuImg = menuimg;
	for (int i = 0; i<10; i++)
	{
		m_JumpImg[i] = jumpimg[i];
	}
}

void CStartUi::Move()
{
	if (m_Pos.x + m_JumpSpeed <= 90)
	{
		m_Pos.x += m_JumpSpeed;
	}
}

void CStartUi::StartUiShow()
{
	cvCopy(m_StartImg2, m_StartBackImg);

	Move();
	Draw2Jump();
	cvShowImage("FRule", m_StartBackImg);
}

void CStartUi::Draw2Jump()
{
	CTools::Draw2Back(m_Pos.x, m_Pos.y, m_StartBackImg, m_JumpImg[m_JumpImgId], 245, 245, 245);
	CTools::Draw2Back(m_Pos.x + 80 , m_Pos.y+120, m_StartBackImg, m_MenuImg, 245, 245, 245);
	m_JumpImgId++;
	if (m_JumpImgId == 10)
	{
		m_JumpImgId = 0;
	}
}
